#ifndef __ORIGINAL_MODIFIED_IO_H__
#define __ORIGINAL_MODIFIED_IO_H__ 1

#include "sample_io.h"
#include "codec.h"

/*
 *                        |
 *  <=== original io ===>   <=== modified io ===>
 *                        |
 *                o---------------o
 *  read EMBED    |       |       | write EMBED
 * -------------->|  embed data   |-------------->
 *                |       |       |
 *                | - - - - - - - |
 *  write EXTRACT |       |       | read EXTRACT
 * <--------------|  extract data |<--------------
 *                |       |       |
 *                o---------------o
 *                        |
 *
 *                        |
 */
class COriginalModifiedIO : public ISampleIO
{
public:
	COriginalModifiedIO(ISampleIO *pOriginalIO, ISampleIO *pModifiedIO);
	virtual ~COriginalModifiedIO();

	/* START methods inherited by ISampleIO */
	virtual int init(CPropertiesReader *pConfig);
	virtual int destroy();

	virtual int read(void** pData, EAction& pAction, int pTimeout = 1000);
	virtual int write(void* pData, const EAction& pAction, int pLength);

	virtual NAudioFormats::SStreamInfo getStreamInfo();
	/* END methods inherited by ISampleIO */

private:
	bool mError;
	bool mUseOriginalForRead;
	ISampleIO *mOriginalIO;
	ISampleIO *mModifiedIO;

	COriginalModifiedIO(const COriginalModifiedIO& );
	COriginalModifiedIO& operator=(const COriginalModifiedIO& );
};

#endif /* __ORIGINAL_MODIFIED_IO_H__ */
